<template>
    <div>
        <el-tabs v-model="currentTab" type="card" class="center-tabs">
            <el-tab-pane label="顾客详情" name="customerDetails" />
            <el-tab-pane label="方案管理" name="projectManagement" />
        </el-tabs>
        <div v-show="currentTab === 'customerDetails'">
            <CustomerDetails :basicInfo="baseInfo" v-if="currentTab === 'customerDetails'"></CustomerDetails>
        </div>
        <div v-show="currentTab === 'projectManagement'">
            <div class="tips" v-if="baseInfo.updateStatus">咨询方案 咨询医生：{{ baseInfo.consultationer }} 咨询日期：{{
                baseInfo.consultationTime }}</div>
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px" class="formBox">
                <el-form-item label="顾客编号" prop="visitNum">
                    <el-input v-model="queryParams.visitNum" placeholder="请输入顾客编号" :disabled="true" clearable
                        style="width: 160px" />
                </el-form-item>
                <el-form-item label="姓名" prop="patientName" label-width="48px">
                    <el-input v-model="queryParams.patientName" placeholder="请输入顾客姓名" :disabled="true" clearable
                        style="width: 140px" />
                </el-form-item>
                <el-form-item label="性别" prop="sex" label-width="48px">
                    <el-select v-model="queryParams.sex" placeholder="下拉选择" :disabled="true" clearable style="width: 60px">
                        <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="状态" prop="status" label-width="48px">
                    <el-select v-model="queryParams.status" placeholder="待咨询" :disabled="true" clearable
                        style="width: 140px">
                        <el-option v-for="dict in dict.type.sys_diagnosis_status" :key="dict.value" :label="dict.label"
                            :value="dict.value" />
                    </el-select>
                </el-form-item>
                <el-form-item label="就诊门诊" prop="patientName">
                  <el-input v-model="queryParams.deptName" placeholder="请输入就诊科室" :disabled="true" clearable
                            style="width: 160px" />
                </el-form-item>
                <el-form-item>
                    <el-badge :value="Listtotal" class="totalItem">
                        <el-button type="primary" size="mini" @click="handleAdd">检测指标</el-button>
                    </el-badge>
                    <el-button type="success" size="mini" @click="updateAllPlan" v-if="baseInfo.updateStatus"
                        :disabled="Number(queryParams.status) >= 3">修改方案</el-button>
                    <el-button type="success" size="mini" @click="saveAllPlan" v-else>保存方案</el-button>
                </el-form-item>
                <el-form-item label="咨询医生">
                    <el-select v-model="queryParams.consultationer" filterable clearable placeholder="咨询医生"
                        style="width: 160px">
                        <el-option v-for="(item, index) in doctorList" :key="index" :label="item.nickName"
                            :value="item.nickName"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <span v-if="latestAppointmentItem && latestAppointmentItem.appointmentDate"
                        style="margin-left: 20px;margin-right: 20px;font-weight: bold;color:red">下次预约日期:{{
                            latestAppointmentItem.appointmentDate }} {{ latestAppointmentItem.week }}
                        {{ latestAppointmentItem.timeSlot == 0 ? '上午' : '下午' }}</span>
                    <el-button type="success" size="mini" @click="addNext">下次预约</el-button>
                </el-form-item>
            </el-form>
            <el-form :model="projectForm" ref="projectForm" size="small" label-width="68px" :rules="projectFormRules"
                label-position="left">
                <div class="formBox">
                    <el-row>
                        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                            <div>

                                <el-form-item label="添加诊断" prop="diseaseClassifyName">
                                    <el-select v-model="projectForm.diseaseClassifyName" filterable placeholder="下拉选择之后点击加入" class="btnInput" :class="device!='mobile'?'w550':'w300'"
                                        clearable  @change="getFxAndFq">
                                        <el-option v-for="item in classifyList" :key="item.diseaseClassifyId"
                                            :label="item.diseaseClassifyName" :value="item.diseaseClassifyName" />
                                    </el-select>
                                    <!-- <el-button size="mini" type="primary" @click="updateDiagnosis" v-if="btnUpdateStatus">修改</el-button> -->
                                    <el-button size="mini" type="primary" @click="addDiagnosis" style="margin-left:15px;"
                                        :disabled="Number(queryParams.status) >= 3">加入</el-button>
                                    <el-button type="success" size="mini" @click="showBaseInfoDataHistory"
                                        style="margin-bottom:10px;">历史咨询记录 <span style="color:red;">({{
                                            baseInfoDataHistoryList.length - 1 }} 次） </span></el-button>
                                    <!-- <el-button size="mini" @click="saveDiagnosis">保存诊断</el-button> -->
                                </el-form-item>
                            </div>
                            <div v-show="Fx.length > 0" class="mt5">
                                <el-form-item label="分型" prop="fxValue">
                                    <!--                                    <el-radio-group v-model="projectForm.fxValue">-->
                                    <!--                                        <el-radio v-for="item in Fx" :key="item" :label="item" :value="item"></el-radio>-->
                                    <!--                                    </el-radio-group>-->
                                    <el-checkbox-group v-model="projectForm.fxValue">
                                        <el-checkbox v-for="(item, index) in Fx" :key="index" :label="item"
                                            :value="item"></el-checkbox>
                                    </el-checkbox-group>
                                </el-form-item>
                            </div>
                            <div v-show="Fq.length > 0" class="mt5">
                                <el-form-item label="分期" prop="fqValue">
                                    <el-radio-group v-model="projectForm.fqValue">
                                        <el-radio v-for="item in Fq" :key="item" :label="item" :value="item"></el-radio>
                                    </el-radio-group>
                                </el-form-item>
                            </div>
                            <div class="mt5 mt15">
                                <el-collapse v-model="activeName" accordion>
                                    <el-form-item label="部位" prop="partId" clearable>
                                        <el-select v-model="projectForm.partId" multiple clearable filterable
                                            @focus="openCollapse" placeholder="请选择部位"  :class="device!='mobile'?'w550':'w300'">
                                            <el-option v-for="(dict,index) in dict.type.sys_face_part" :key="index"
                                                :label="dict.label" :value="dict.label"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="" prop="partId">
                                        <el-collapse-item name="1">
                                            <el-checkbox-group v-model="projectForm.partId">
                                                <el-checkbox v-for="(dict,index) in dict.type.sys_face_part" :key="index"
                                                    :label="dict.label" :value="dict.label"
                                                    style="width: 100px;"></el-checkbox>
                                            </el-checkbox-group>
                                        </el-collapse-item>
                                    </el-form-item>

                                </el-collapse>

                            </div>

                        </el-col>
                        <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                            <div v-for="item in diagnosisList" :key="item.id" class="mt5">
                                <el-form-item label="诊断">
                                    <el-input v-model="item.diagnosis" placeholder="请输入诊断" disabled clearable :class="device!='mobile'?'w550':'w300'"
                                        style="margin-bottom:15px" />
                                    <!-- <el-button size="mini" @click="updateItemDiagnosis(item)">修改</el-button> -->
                                    <el-button size="mini" @click="delDiagnosis(item)" style="margin-left:15px;"
                                        :disabled="Number(queryParams.status) >= 3">删除</el-button>
                                </el-form-item>
                            </div>
                            <div>
                                <el-form-item label="主诉" prop="consultationNote">
                                    <el-input v-model="projectForm.consultationNote" placeholder="请输入主诉" clearable :class="device!='mobile'?'w550':'w300'"
                                        style="margin-bottom:15px" />
                                </el-form-item>
                            </div>
                            <div>
                                <el-form-item label="现病史" prop="diagnosisMedical">
                                    <el-input v-model="projectForm.diagnosisMedical" type="textarea" :rows="6" :class="device!='mobile'?'w550':'w300'"
                                        placeholder="请输入现病史" clearable style="margin-bottom:15px" />
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>
                </div>
            </el-form>
            <el-form size="small" :inline="true" label-width="68px">
                <div class="formBox">
                    <div class="formBox">
                        <el-row>
                            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                                <div>
                                    <el-form-item label="添加套餐" prop="mealId">
                                        <el-select v-model="projectForm.mealId" filterable placeholder="下拉选择之后点击加入"
                                            clearable style="width: 330px">
                                            <el-option v-for="item in mealList" :key="item.setMealId"
                                                :label="item.setMealName" :value="item.setMealId" />
                                        </el-select>
                                        <el-button size="mini" @click="addPackage" type="primary" style="margin-left:15px;"
                                            :disabled="Number(queryParams.status) >= 3">加入</el-button>
                                    </el-form-item>
                                </div>
                                <div style="margin-top:8px">
                                    <el-form-item label="添加单项" prop="planCategoryId" clearable>
                                        <el-select v-model="projectForm.planCategoryId" filterable @change="changeList"
                                            placeholder="请选择方案大类" clearable style="width: 160px">
                                            <el-option v-for="dict in dict.type.sys_plan_category" :key="dict.value"
                                                :label="dict.label" :value="dict.value"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="" prop="planId">
                                        <el-select v-model="projectForm.planId" filterable placeholder="请选择专病名称" clearable
                                            style="width: 160px">
                                            <el-option v-for="(item, index) in singlePlanList" :key="index"
                                                :label="item.medicalEquipment" :value="item.planId"></el-option>
                                        </el-select>
                                        <el-button size="mini" @click="addSingle" type="primary" style="margin-left:15px;"
                                            :disabled="Number(queryParams.status) >= 3">加入</el-button>
                                    </el-form-item>
                                </div>
                            </el-col>
                            <!--                        <el-col :span="3" class="price"> 治疗费/总金额 <br />{{ treatmentExpenses }}/{{ totalExpenses}}</el-col>-->
                            <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="price" style="margin-top:8px">
                                <div>治疗费:{{ treatmentExpenses }}</div>
                                <div>总金额:{{ totalExpenses }}</div>
                            </el-col>
                        </el-row>
                    </div>
                    <div class="formBox">
                        <el-table :data="sysSetMealPlanListCopy" border>
                            <el-table-column fixed="left" label="操作" align="center" class-name="small-padding fixed-width"
                                width="100">
                                <template slot-scope="scope">
                                    <el-button size="mini" type="text" icon="el-icon-delete"
                                        @click="deletePlanItem(scope.row)">删除</el-button>
                                </template>
                            </el-table-column>
                            <el-table-column label="类别" align="center" prop="category" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.category === '1' ? '套餐' : scope.row.category === '2' ? '单项' : ''
                                    }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column label="套餐名称" align="center" prop="packageName" :show-overflow-tooltip="true"
                                width="200" />

                            <el-table-column label="项目类别" align="center" prop="planCategoryId"
                                :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <span>{{ matchDict("sys_plan_category", scope.row.planCategoryId) }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column label="方案名称" align="left" prop="packageContent" :show-overflow-tooltip="true"
                                width="220" />
                            <!-- <el-table-column label="医嘱参数" align="center" prop="frequency" :show-overflow-tooltip="true"
                                width="160">
                                <template slot-scope="scope">
                                    <el-select v-model="scope.row.parameters" multiple clearable placeholder="请选择医嘱参数"
                                        filterable allow-create>
                                        <el-option v-for="dict in treatmentParameterList" :key="dict.label"
                                            :label="dict.label" :value="dict.label"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column> -->

                            <el-table-column label="医嘱参数值" align="center" prop="parameters" :show-overflow-tooltip="true"
                                width="150">
                                <template slot-scope="scope">
                                    <el-tooltip placement="right" effect="light"
                                        v-if="scope.row.planCategoryId == 2 && scope.row.parametersList ? scope.row.parametersList.length > 0 : false"
                                        :disabled="isShowStatus">
                                        <div slot="content">
                                            <div style="display: flex;margin-bottom:15px"
                                                v-for="item in scope.row.parametersList" :key="item.label">
                                                <el-input v-model="item.label" placeholder="请输入医嘱名称"
                                                    style="margin-right:15px;"></el-input>
                                                <el-input v-model="item.value" placeholder="请输入医嘱参数值"
                                                    style="margin-right:15px;"></el-input>
                                                <el-button size="mini" type="primary"
                                                    @click="delOptions(item, scope.$index)">删除</el-button>
                                            </div>
                                            <el-button size="mini" type="primary" style="display: block; margin:15px auto"
                                                @click="submitOptions(scope.$index)">提交</el-button>
                                        </div>
                                        <el-input v-model="scope.row.parameters" placeholder="请输入医嘱参数值"></el-input>
                                    </el-tooltip>
                                    <el-input v-else v-model="scope.row.parameters" placeholder="请输入医嘱参数值"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="用法" align="center" prop="treatmentModalities"
                                :show-overflow-tooltip="true" width="130">
                                <template slot-scope="scope">
                                    <el-select v-model="scope.row.treatmentModalities" filterable clearable
                                        placeholder="请选择用法">
                                        <el-option v-for="dict in treatmentMethodsList" :key="dict.label"
                                            :label="dict.label" :value="dict.label"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column label="结算价" align="center" prop="discountPrice" :show-overflow-tooltip="true"
                                width="120">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.discountPrice" placeholder="请输入结算价"
                                        type="number"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="用量" align="center" prop="dosage" :show-overflow-tooltip="true"
                                width="100">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.dosage" placeholder="请输入用量" type="number"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="单位" align="center" prop="numUnit" :show-overflow-tooltip="true"
                                width="100">
                                <template slot-scope="scope">
                                    <el-select v-model="scope.row.numUnit" filterable placeholder="请选择用量单位">
                                        <el-option v-for="dict in numUnitList" :key="dict.label" :label="dict.label"
                                            :value="dict.label"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column label="频次" align="center" prop="frequency" :show-overflow-tooltip="true"
                                width="130">
                                <template slot-scope="scope">
                                    <el-select v-model="scope.row.frequency" placeholder="请选择频次" filterable allow-create>
                                        <!-- <el-option v-for="dict in dict.type.sys_dosage_frequency" :key="dict.label"
                                :label="dict.label" :value="dict.label"></el-option> -->
                                        <el-option v-for="dict in frequencyList" :key="dict.label" :label="dict.label"
                                            :value="dict.value"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column label="数量" align="center" prop="num" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.num" placeholder="请输入数量" type="number"
                                        @input="numInput(scope.row)" @keydown.native="onlyWriteNum"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="点位数" align="center" prop="pointsNum" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.pointsNum" placeholder="点位数" type="number"
                                        @input="pointsNumInput(scope.row)"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="单价" align="center" prop="price" :show-overflow-tooltip="true"
                                width="120">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.price" placeholder="请输入单价" type="number"
                                        @input="priceInput(scope.row)"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="总价" align="center" prop="totalPrice" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    {{ scope.row.num * scope.row.pointsNum * scope.row.price }}
                                </template>
                            </el-table-column>
                            <!-- <el-table-column label="优惠率" align="center" prop="discount" width="80">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.discount" size="mini" :precision="2" :step="0.01" :min="0"
                                        :max="1" type="number"></el-input></template>
                            </el-table-column> -->

                            <el-table-column label="先敷药" align="center" prop="isApplication" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <span>{{ scope.row.isApplication == 0 ? '是' : (scope.row.isApplication == 1 ? '否' : '')
                                    }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column label="治疗仪器" align="center" prop="instruments" :show-overflow-tooltip="true" />
                            <el-table-column label="领取地点" align="center" prop="pickingLocation" width="202">
                                <template slot-scope="scope">
                                    <el-select v-model="scope.row.pickingLocation" filterable clearable placeholder="领取地点"
                                        style="width: 180px">
                                        <el-option v-for="dict in dict.type.sys_picking_location" :key="dict.value"
                                            :label="dict.label" :value="dict.value"></el-option>
                                    </el-select>
                                </template>
                            </el-table-column>
                            <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true"
                                width="200">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.remark" placeholder="请输入备注"></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="创建时间" align="center" prop="createTime" width="160">
                                <template slot-scope="scope">
                                    <span>{{ parseTime(scope.row.createTime) }}</span>
                                </template>
                            </el-table-column>
                        </el-table>
                    </div>
                </div>
            </el-form>
        </div>
        <!-- 新增检测指标 -->
        <el-dialog :title="planTitle" :visible.sync="centerDialogVisible" v-dialogDrag width="90%" append-to-body
            :close-on-click-modal="false">
            <detectionAdd v-if="centerDialogVisible" :baseAdd="baseAdd" @closeCenterDialogVisible="closeCenterDialogVisible"
                @refresh="closeCenterDialogVisible">
            </detectionAdd>
        </el-dialog>
        <!-- 咨询记录 -->
        <el-dialog title="历史咨询记录" :visible.sync="historyVisible" v-dialogDrag width="1000px" append-to-body
            :close-on-click-modal="false">
            <el-collapse v-model="historyactiveName" accordion>
                <el-collapse-item
                    :title="gethospital(item.hospitalName) + '  ' + '顾客编号：' + item.visitNum + ' 登记日期：' + parseTime(item.createTime) + ' 状态：' + getDiagnosisStatusLabel(item.status) + ' 诊断：' + item.consultationDiagnosis"
                    v-for="(item, index) in baseInfoDataHistoryList" :key="index" :name="index"
                    v-if="item.visitNum != baseInfo.visitNum">
                    <template slot="title">
                        <div style="width: 100%;
                        overflow: hidden;
                        text-overflow: ellipsis;
                        white-space: nowrap;">
                            {{ gethospital(item.hospitalName) }}顾客编号：{{ item.visitNum }} 登记日期：{{ parseTime(item.createTime)
                            }}
                            状态：{{ getDiagnosisStatusLabel(item.status) }} 诊断：{{ item.consultationDiagnosis }}
                        </div>
                    </template>
                    <el-row style="font-size:15px">
                        <el-col :span="6">顾客编号:{{ item.visitNum }}</el-col>
                        <el-col :span="6">手机:{{ item.patientPhone }}</el-col>
                        <el-col :span="3">顾客ID:{{ item.patientId }}</el-col>
                        <el-col :span="3">状态:{{ matchDict("sys_diagnosis_status", item.status) }}</el-col>
                        <el-col :span="3">卡号:{{ item.cardNumber }}</el-col>
                        <el-col :span="3">顾客分类:{{ matchDict("sys_patient_sort", item.customerSort) }}</el-col>
                        <el-col :span="3">皮肤色度:{{ matchDict("sys_skin_tone", item.tone) }}</el-col>
                    </el-row>
                    <el-row style="font-size:15px">
                        <el-col :span="6">患者地址:{{ item.area }}</el-col>
                        <el-col :span="6">详细地址:{{ item.address }}</el-col>
                        <el-col :span="3">顾客性质:{{ matchDict("sys_patient_properties", item.properties) }}</el-col>
                        <el-col :span="3">职业:{{ item.job }}</el-col>
                        <el-col :span="3">微信号:{{ item.wxNum }}</el-col>

                    </el-row>
                    <el-row style="font-size:15px">
                        <el-col :span="24">就诊门诊:<span style="color:red;font-size:15px;font-weight:700;">{{ item.deptName
                        }}</span></el-col>
                    </el-row>

                    <el-row style="font-size:15px">
                        <el-col :span="24">咨询诊断:<span style="color:red;font-size:15px;font-weight:700;">{{
                            item.consultationDiagnosis }}</span></el-col>
                    </el-row>
                    <el-row style="font-size:15px">
                        <el-col :span="24">咨询方案:<span style="color:red;font-size:15px;font-weight:700;">{{
                            item.consultationPlan }}</span></el-col>
                    </el-row>
                    <el-row style="font-size:15px">
                        <el-col :span="6">咨询医生:{{ item.consultationer }}</el-col>
                        <el-col :span="6">咨询时间:{{ item.consultationTime }}</el-col>
                        <el-col :span="6">方案总额:{{ item.consultationTotalExpenses }}</el-col>
                        <el-col :span="6">治疗费用:{{ item.consultationTreatmentExpenses }}</el-col>
                    </el-row>
                    <el-row style="font-size:15px">
                        <el-col :span="4">备注:{{ item.remark }}</el-col>
                    </el-row>
                    <el-row style="font-size:15px;float:right">
                        <el-button size="mini" @click="addPlan(item.visitNum)" type="primary"
                            style="margin-left:15px;margin-bottom:10px;"
                            :disabled="item.consultationDiagnosis ? false : true">引用方案</el-button>
                    </el-row>
                </el-collapse-item>
            </el-collapse>
        </el-dialog>
        <!-- 下次预约 -->
        <el-dialog title="预约" :visible.sync="appointReservaDialogVisible" v-dialogDrag width="80%" append-to-body
            :close-on-click-modal="false" @close="closeAppointReserva">
            <appointReservate v-if="appointReservaDialogVisible" :basicInfo="baseInfo">
            </appointReservate>
        </el-dialog>
    </div>
</template>

<script>
import { mapGetters } from "vuex";
import { latestAppointment } from "@/api/appointManage/appointReserve";
import {
    listClassify,
} from "@/api/system/classify";
import {
  listPlan,
  listMeal,
  getMeal, listMealDept, listPlanDept,
} from "@/api/system/plan";
import {
    consultationList,
    savePlan,
    consultationEdit,
    updatePlan
} from "@/api/consultation/consultation";
import appointReservate from "@/views/components/customerDetail/appointReservate";
import detectionAdd from "@/views/components/detection/add";
import CustomerDetails from '@/views/components/customerDetail/customerDetail'
import { addDoctorPlan } from "@/api/doctorWorkstation/diagnosisList";
import { getListUser } from "@/api/system/user";
import { listDetectionVisit } from "@/api/photoWorkstation/detection";
export default {
    name: "Detail",
    dicts: ['sys_diagnosis_status', 'sys_patient_properties', 'sys_skin_tone', 'sys_patient_sort', 'sys_user_sex', 'sys_manage_diseases', 'sys_face_part', "sys_normal_disable", "sys_plan_category", "sys_dosage_unit", "sys_treatment_instrument", "sys_treatment_parameter", "sys_dosage_frequency", "sys_plan_usage", "sys_yes_no", "sys_picking_location",
    ],
    props: ['baseInfo'],
    components: { CustomerDetails, detectionAdd, appointReservate },
    data() {
        return {
            historyVisible: false,
            historyactiveName: 1,
            baseInfoDataHistoryList: [],
            baseAdd: {},
            planTitle: '',
            centerDialogVisible: false,
            currentTab: 'projectManagement',
            classifyList: [],
            Fx: [],
            Fq: [],
            diagnosisList: [],
            btnUpdateStatus: false,
            currentDiagnosis: null,
            singlePlanList: [],
            mealList: [],
            sysSetMealPlanList: [],
            // 查询参数
            queryParams: {
                visitNum: undefined, //顾客编号
                patientName: undefined,//顾客姓名
                sex: undefined,//顾客性别
                status: undefined,//状态
                consultationer: '',
                deptName:'',
            },
            // projectForm: { diseaseClassifyName: '', fxValue: '', fqValue: '', partId: [], mealId: '', planId: '', planCategoryId: '', diagnosisMedical: '', consultationNote: '' },
            projectForm: { diseaseId: '', diseaseClassifyName: '', fxValue: [], fqValue: '', partId: [], mealId: '', planId: '', planCategoryId: '', diagnosisMedical: '', consultationNote: '' },
            sysSetMealPlanListCopy: [],
            frequencyList: [],
            treatmentMethodsList: [],
            numUnitList: [],
            treatmentParameterList: [],
            consultationPlanText: '',
            isShowStatus: false,
            projectFormRules: {
                partId: [
                    {
                        required: true,
                        message: "部位不能为空",
                        trigger: "blur",
                    },
                ],
            },
            // 折叠面板
            activeName: '',
            //专属医生列表
            doctorList: [],
            userName: this.$store.state.user.name,
            nickName: this.$store.state.user.nickName,
            Listtotal: 0,
            appointReservaDialogVisible: false,
            latestAppointmentItem: {}
        };
    },

    computed: {
        ...mapGetters(["device"]),
        totalExpenses: function () {
            let all = 0
            this.sysSetMealPlanListCopy.forEach(item => {
                if (item.num * item.pointsNum * item.price < item.discountPrice) {
                  //  setTimeout(() => { this.$message.warning(`${item.packageContent}结算价大于总价，请检查`) }, 10)
                }
                all += Number(item.discountPrice)
            })
            return all.toFixed(2)
        },
        treatmentExpenses: function () {
            let all = 0
            this.sysSetMealPlanListCopy.forEach(item => {
                if (item.packageNum === 2) {
                    all += Number(item.discountPrice)
                }
            })
            console.log(all)
            return all.toFixed(2)
        },
    },
    mounted() {
      console.log('this.baseInfo--',this.baseInfo)
        this.queryParams.visitNum = this.baseInfo.visitNum
        this.queryParams.patientName = this.baseInfo.patientName
        this.queryParams.sex = this.baseInfo.sex
        this.queryParams.status = this.baseInfo.status
        this.queryParams.deptName = this.baseInfo.deptName
        //获取检测指标
        this.getlistDetectionVisit()
        this.getClassifyList()
        this.getMealList()
        this.getConsultationerList()
        this.getBaseInfoDataHistoryLists()
        this.getlatestAppointment()
        if (this.baseInfo.updateStatus) {
            this.getConsultationEditInfo()
        }
        let that = this
        setTimeout(function () {
            that.dict.type.sys_dosage_frequency.forEach(item => {
                that.frequencyList.push({ label: item.label, value: item.label })
            })
            that.dict.type.sys_plan_usage.forEach(item => {
                that.treatmentMethodsList.push({ label: item.label, value: item.label })
            })
            that.dict.type.sys_dosage_unit.forEach(item => {
                that.numUnitList.push({ label: item.label, value: item.label })
            })
            that.dict.type.sys_treatment_parameter.forEach(item => {
                that.treatmentParameterList.push({ label: item.label, value: item.label })
            })


        }, 1000)
    },
    methods: {
        getlatestAppointment() {
            latestAppointment({
                patientId: this.baseInfo.patientId,
            }).then(response => {
                if (response.code == 200) {
                    this.latestAppointmentItem = response.data
                }
            })
        },
        addNext() {
            this.appointReservaDialogVisible = true
        },
        closeAppointReserva() {//关闭弹窗
            this.appointReservaDialogVisible = false
            this.getlatestAppointment()
        },
        //获取指标录入列表
        getlistDetectionVisit() {
            let detectionIndexForm = {
                pageNum: 1,
                pageSize: 10,
                visitNum: '',
                patientId: ''
            }
            detectionIndexForm.visitNum = this.baseInfo.visitNum
            listDetectionVisit(detectionIndexForm).then(
                (response) => {
                    if (response.rows.length > 0) {
                        this.Listtotal = response.total;
                    } else {
                        this.Listtotal = 0;
                    }
                }
            )
        },
        addPlan(visitNum) {
            this.sysSetMealPlanListCopy = []
            this.getConsultationEditInfo(1, visitNum)
            this.historyVisible = false
        },
        // 获取顾客咨询历史列表
        showBaseInfoDataHistory() {
            if (this.baseInfoDataHistoryList.length > 1) {
                this.historyVisible = true
            }
        },
        gethospital(str) {
            if (str) {
                return str
            } else {
                return ''
            }
        },
        //获取诊断状态字典值对应的label
        getDiagnosisStatusLabel(status) {
            let label = ''
            this.dict.type.sys_diagnosis_status.forEach((item) => {
                if (item.value == status) {
                    label = item.label
                }
            })
            return label

        },
        // 获取顾客登记列表

        getBaseInfoDataHistoryLists() {
            const patientId = this.baseInfo.patientId
            const queryParams = { pageNum: 1, pageSize: 9999, patientId: patientId }
            consultationList(queryParams).then((response) => {
                this.baseInfoDataHistoryList = response.rows;
                this.baseInfoDataHistoryList.forEach(item => {
                    if (item.consultationDiagnosis.includes(';')) {
                        let Mobject = ''
                        item.consultationDiagnosis.split(';').forEach(it => {
                            Mobject += it + '<br>'
                        })
                        item.consultationDiagnosisValue = Mobject
                    } else {
                        item.consultationDiagnosisValue = item.consultationDiagnosis
                    }
                });

            })


        },
        onlyWriteNum(e) {
            e.returnValue = (['e', 'E', '-', '+', '.'].includes(e.key)) ? false : e.returnValue
            return e
        },
        numInput(row) {
            this.sysSetMealPlanListCopy.forEach((item, index) => {
                if (row.packageContent == item.packageContent) {
                    item.discountPrice = item.num * item.pointsNum * item.price
                }
            })
        },
        pointsNumInput(row) {
            this.sysSetMealPlanListCopy.forEach((item, index) => {
                if (row.packageContent == item.packageContent) {
                    item.discountPrice = item.num * item.pointsNum * item.price
                }
            })
        },
        priceInput(row) {
            this.sysSetMealPlanListCopy.forEach((item, index) => {
                if (row.packageContent == item.packageContent) {
                    item.discountPrice = item.num * item.pointsNum * item.price
                }
            })
        },
        //查询咨询医生
        getConsultationerList() {
            getListUser({ funcRole: '1',hospitalId:this.baseInfo.hospitalId,deptId:this.baseInfo.deptId }).then((response) => {
                if (response.code == 200) {
                    this.doctorList = response.data
                    if (this.doctorList.length > 0) {
                        let a = this.doctorList.some(item => {
                            return item.nickName == this.nickName
                        })
                        if (this.baseInfo.consultationer) {
                            this.queryParams.consultationer = this.baseInfo.consultationer
                        } else {
                            if (a) {
                                this.queryParams.consultationer = this.nickName
                            }
                        }

                    }
                }
            });
        },
        // 录入指标 saveDetection
        handleAdd() { //新增检测指标
            this.baseAdd = {};
            this.baseAdd.isDetail = true;
            this.baseAdd.visitNum = this.queryParams.visitNum
            this.baseAdd.patientName = this.queryParams.patientName
            this.baseAdd.patientId = this.baseInfo.patientId
            this.baseAdd.deptId = this.baseInfo.deptId
            console.log(this.baseAdd)
            this.planTitle = "检测指标";
            this.centerDialogVisible = true;
        },
        closeCenterDialogVisible() {
            this.centerDialogVisible = false
            this.getlistDetectionVisit()
        },
        /** 医嘱参数值悬浮时提交值 */
        submitOptions(index) {
            let text = ''
            this.sysSetMealPlanListCopy[index].parametersList.forEach((item, index) => {
                text += item.label + '(' + item.value + ');'
            })
            this.sysSetMealPlanListCopy[index].parameters = text
            this.isShowStatus = true
            setTimeout(() => {
                this.isShowStatus = false
            }, 500)
            this.$message.success('医嘱参数提交成功')



        },
        /** 医嘱参数值悬浮时删除值 */
        delOptions(row, index) {
            this.sysSetMealPlanListCopy[index].parametersList = this.sysSetMealPlanListCopy[index].parametersList.filter(item => { return item.label != row.label })
        },
        /** 删除方案信息 */
        deletePlanItem(row) {
            this.arr = JSON.stringify(this.sysSetMealPlanListCopy)
            this.sysSetMealPlanListCopy = JSON.parse(this.arr).filter((item) => {
                return row.packageContent != item.packageContent
            })
        },
        /** 获取方案信息 */
        getConsultationEditInfo(type, Num) {//type==1  引用方案   其它为修改方案
            let visitNum = this.queryParams.visitNum
            if (type == 1) {
                visitNum = Num
            }
            consultationEdit(visitNum).then((res) => {
                if (type == 1) {//&&this.baseInfo.updateStatus
                    this.baseInfo.id = this.baseInfo.id

                } else {
                    this.baseInfo.id = res.Info[0].id
                }

                this.diagnosisList = JSON.parse(res.Info[0].consultationDiagnosis)
                this.projectForm.consultationNote = res.Info[0].consultationNote
                this.projectForm.diagnosisMedical = res.Info[0].diagnosisMedical
                res.plan.rows.forEach((item, index) => {
                    this.queryParams.consultationer = item.nickName
                    this.sysSetMealPlanListCopy.push({
                        pointsNum: item.pointsNum ? item.pointsNum : 1,
                        planCategoryId: item.planCategoryId,
                        treatmentType: item.planCategoryId == '2' ? '治疗类' : '',
                        searchValue: item.searchValue,
                        createBy: item.createBy,
                        createTime: item.createTime,
                        updateBy: item.updateBy,
                        updateTime: item.updateTime,
                        remark: item.remark,
                        params: {},
                        id: item.id,
                        visitNum: this.queryParams.visitNum,
                        type: item.type,
                        category: item.category,
                        treatmentModalities: item.treatmentModalities,
                        packageName: item.packageName,
                        packageNum: item.packageNum,
                        packageContent: item.packageContent,
                        frequency: item.frequency,
                        dosage: item.dosage,
                        num: item.num,
                        numUnit: item.numUnit,
                        price: item.price,
                        priceUnit: item.priceUnit,
                        discount: item.discount,
                        totalPrice: Number(item.num * item.pointsNum * item.price),
                        diagnosisResult: item.diagnosisResult,
                        diagnosisMedical: item.diagnosisMedical,
                        diagnosisNote: item.diagnosisNote,
                        expenses: item.expenses,
                        status: item.status,
                        instruments: item.instruments,
                        instrumentsIds: item.instrumentsIds,
                        parameters: item.parameters ? this.getParametersValue(item.parameters) : null,
                        parametersList: item.parameters ? JSON.parse(item.parameters) : null,
                        isApplication: item.isApplication,
                        sPlanId: item.sPlanId,
                        pickingLocation: item.pickingLocation,
                        discountPrice: item.discountPrice ? item.discountPrice : Number(item.num * item.pointsNum * item.price)
                    })
                })
            })
        },
        getParametersValue(row) {
            console.log(row)
            let text = ''
            JSON.parse(row).forEach((item, index) => {
                text += item.label + '(' + item.value + ');'
            })
            return text
        },
        /** 数组对象去重 */
        uniqueFunc(arr, uniId) {
            const res = new Map();
            return arr.filter((item) => !res.has(item[uniId]) && res.set(item[uniId], 1));
        },
        /** 方案数据提取咨询方案文本 */
        getConsultationPlanText() {
            let packageArr = this.sysSetMealPlanListCopy.filter(item => { return item.category == '1' })
            //根据套餐名称去重
            let distinctPackageArr = this.uniqueFunc(packageArr, 'packageName')
            let singleArr = this.sysSetMealPlanListCopy.filter(item => { return item.category == '2' })
            distinctPackageArr.forEach(item => {
                let mArr = this.sysSetMealPlanListCopy.filter(mIt => { return item.packageName == mIt.packageName })
                this.consultationPlanText += item.packageName + '{'
                mArr.forEach((mItem, index) => {
                    if (index == mArr.length - 1) {
                        this.consultationPlanText += mItem.packageContent + '*' + mItem.num + '};'
                    } else {
                        this.consultationPlanText += mItem.packageContent + '*' + mItem.num + '、'
                    }
                })
            })
            singleArr.forEach(item => {
                this.consultationPlanText += item.packageContent + '*' + item.num + ';'
            })
        },
        /** 修改方案所有信息 */
        updateAllPlan() {
            if (!this.queryParams.consultationer) {
                this.$message.warning('请选择诊断医生!')
                return
            }
            let a = this.doctorList.find(item => {
                return item.nickName == this.queryParams.consultationer
            })
            this.getConsultationPlanText()
            console.log('this.sysSetMealPlanListCopy---', this.sysSetMealPlanListCopy)
            let Mdata = {
                id: this.baseInfo.id,
                visitNum: this.baseInfo.visitNum,
                consultationDiagnosis: JSON.stringify(this.diagnosisList),
                consultationNote: this.projectForm.consultationNote,
                diagnosisMedical: this.projectForm.diagnosisMedical,
                sysVisitPlan: this.sysSetMealPlanListCopy.map(item => ({
                    ...item, parameters: item.parametersList ? JSON.stringify(item.parametersList) : null, totalPrice: Number(item.num * item.pointsNum * item.price),
                })),
                totalExpenses: this.totalExpenses,
                treatmentExpenses: this.treatmentExpenses,
                consultationPlan: this.consultationPlanText,
                nickName: this.queryParams.consultationer,
                consultationUserName: a.userName
            }
            // console.log('this.queryParams.status---',this.queryParams.status)
            if (Number(this.queryParams.status) > 1) {
                this.$message.warning('已流转至医生方案,且医生方案已存在,不可更改!')
            } else {

                if (this.diagnosisList.length == 0) {
                    this.$message.warning('请添加诊断!')
                } else {
                    if (Mdata.sysVisitPlan.length > 0) {
                        const isExit = !!Mdata.sysVisitPlan.find(item => {
                            return item.num == null || item.num == 0
                        })
                        if (isExit) {
                            this.$message.warning('存在数量为0的单项，请仔细核对')
                        } else {
                            updatePlan(Mdata).then((res) => {
                                if (res.code === 200) {
                                    this.$message.success('修改成功')
                                    this.$emit('closeCenterDialogVisible')
                                }
                            })
                        }
                    } else {
                        this.$confirm('该顾客没有方案?请确认', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        })
                            .then((content) => {
                                updatePlan(Mdata).then((res) => {
                                    if (res.code === 200) {
                                        this.$message.success('修改成功')
                                        this.$emit('closeCenterDialogVisible')
                                    }
                                })
                            })
                            .catch((error) => {
                                // console.log('error', error)
                            })
                    }
                }

                // if (Mdata.sysVisitPlan.length > 0) {
                //     updatePlan(Mdata).then((res) => {
                //         if (res.recognizeCode === 200) {
                //             this.$message.success('修改成功')
                //             this.$emit('closeCenterDialogVisible')
                //         }
                //     })
                // } else {
                //     this.$message.warning('请添加套餐或单项!')
                // }
            }


        },
        /** 保存方案所有信息 */
        saveAllPlan() {
            if (!this.queryParams.consultationer) {
                this.$message.warning('请选择咨询医生!')
                return
            }
            let a = this.doctorList.find(item => {
                return item.nickName == this.queryParams.consultationer
            })

            this.getConsultationPlanText()
            let Mdata = {
                visitNum: this.baseInfo.visitNum,
                consultationDiagnosis: JSON.stringify(this.diagnosisList),
                consultationNote: this.projectForm.consultationNote,
                diagnosisMedical: this.projectForm.diagnosisMedical,
                sysVisitPlan: this.sysSetMealPlanListCopy.map(item => ({
                    ...item, parameters: item.parametersList ? JSON.stringify(item.parametersList) : null, totalPrice: Number(item.num * item.pointsNum * item.price),
                })),
                totalExpenses: this.totalExpenses,
                treatmentExpenses: this.treatmentExpenses,
                consultationPlan: this.consultationPlanText,
                nickName: this.queryParams.consultationer,
                consultationUserName: a.userName
            }

            if (this.diagnosisList.length == 0) {
                this.$message.warning('请添加诊断!')
            } else {
                if (Mdata.sysVisitPlan.length > 0) {
                    const isExit = !!Mdata.sysVisitPlan.find(item => {
                        return item.num == null || item.num == 0
                    })
                    if (isExit) {
                        this.$message.warning('存在数量为空的单项，请仔细核对')
                    } else {
                        savePlan(Mdata).then((res) => {
                            if (res.code === 200) {
                                this.$message.success('新增成功')
                                this.$emit('closeCenterDialogVisible')
                            }
                        })
                    }

                } else {
                    this.$confirm('该顾客没有方案?请确认', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    })
                        .then((content) => {
                            savePlan(Mdata).then((res) => {
                                if (res.code === 200) {
                                    this.$message.success('新增成功')
                                    this.$emit('closeCenterDialogVisible')
                                }
                            })
                        })
                        .catch((error) => {
                            // console.log('error', error)
                        })
                }
            }


            // if (Mdata.sysVisitPlan.length > 0) {
            //     savePlan(Mdata).then((res) => {
            //         if (res.recognizeCode === 200) {
            //             this.$message.success('新增成功')
            //             this.$emit('closeCenterDialogVisible')
            //         }
            //     })
            // } else {
            //     this.$message.warning('请添加套餐或单项!')
            // }

        },
        /** id转化成对应的文字 */
        matchDict: function (key, id) {
            let _this = this;
            const result = _this.dict.type[key];
            let textValue = "";
            result.forEach((item) => {
                if (item.raw.dictValue == id) {
                    textValue = item.raw.dictLabel;
                }
            });
            return textValue;
        },

        /** 获取套餐列表 */
        getMealList() {
          listMealDept({
                pageNum: 1,
                pageSize: 9999,
                status: 0,
                deptId:this.baseInfo.deptId,
            }).then(
                (response) => {
                    this.mealList = response.rows;
                }
            );
        },
        changeList() {
            this.singlePlanList = []
            this.projectForm.planId = ''
            this.getSinglePlanList()
        },
        /** 获取单项列表 */
        getSinglePlanList() {
          listPlanDept({
                pageNum: 1,
                pageSize: 9999,
                status: 0,
                planCategoryId: this.projectForm.planCategoryId,
                deptId:this.baseInfo.deptId,
            }).then(
                (response) => {
                    this.singlePlanList = response.rows;
                }
            );
        },
        /** 查询专病列表 */
        getClassifyList() {
            listClassify(
                {
                    pageNum: 1,
                    pageSize: 9999,
                    status: 0
                }
            ).then((response) => {
                this.classifyList = response.rows;
            });
        },
        /** 专病名称选择后筛选出分型和分期 */
        getFxAndFq(row) {
            console.log(row)
            this.activeName = '1'
            this.classifyList.forEach(item => {
                if (item.diseaseClassifyName === row) {
                    this.projectForm.diseaseId = item.diseaseClassifyId
                    this.Fx = JSON.parse(item.diseaseType)
                    this.Fq = JSON.parse(item.diseaseSerialization)
                }
            })

        },
        openCollapse() {
            this.activeName = '1'
        },
        /** 添加套餐 */
        addPackage() {
            const that = this
            if (!this.projectForm.mealId) {
                this.$message.warning('请选择套餐')
            } else {
                getMeal(this.projectForm.mealId).then(
                    (response) => {
                        console.log('addPackage--', response)
                        let warnText = ''
                        response.data.sysSetMealPlanList.forEach(item => {
                            let isExist = this.sysSetMealPlanListCopy.filter(it => { return item.planId == it.sPlanId })
                            if (isExist.length > 0) {
                                warnText = warnText + isExist[0].packageContent + ','
                            } else {
                                that.sysSetMealPlanListCopy.push({
                                    pointsNum: 1,//点位数
                                    planCategoryId: item.planCategoryId,
                                    treatmentType: item.planCategoryId == '2' ? '治疗类' : '',
                                    packageContent: item.medicalEquipment,
                                    searchValue: item.searchValue,
                                    createBy: item.createBy,
                                    createTime: item.createTime,
                                    updateBy: item.updateBy,
                                    updateTime: item.updateTime,
                                    remark: item.remark,
                                    params: {},
                                    id: 0,
                                    sPlanId: item.planId,
                                    visitNum: item.visitNum,
                                    type: "1",
                                    category: '1',
                                    treatmentModalities: that.matchDict("sys_plan_usage", item.usageId),
                                    packageName: response.data.setMealName,
                                    packageNum: Number(item.planCategoryId),
                                    frequency: that.matchDict("sys_dosage_frequency", item.frequencyId),
                                    dosage: item.dosage,
                                    num: item.num ? item.num : 1,
                                    numUnit: that.matchDict("sys_dosage_unit", item.dosageUnit),
                                    price: item.price,
                                    priceUnit: item.priceUnit,
                                    discount: item.discount,
                                    diagnosisResult: item.diagnosisResult,
                                    diagnosisMedical: item.diagnosisMedical,
                                    diagnosisNote: item.diagnosisNote,
                                    expenses: item.expenses,
                                    status: item.status,
                                    instruments: item.instruments,
                                    instrumentsIds: item.instrumentsIds,
                                    isApplication: item.isApplication,
                                    parameters: item.parameters ? this.getParametersValue(item.parameters) : null,
                                    parametersList: item.parameters ? JSON.parse(item.parameters) : null,
                                    pickingLocation: item.pickingLocation,
                                    totalPrice: Number(item.num * item.price),  //添加单项时不用乘item.pointsNum   添加时item.pointsNum默认为1
                                    discountPrice: item.discountPrice ? item.discountPrice : Number(item.num * item.price),//添加单项时不用乘item.pointsNum   添加时item.pointsNum默认为1
                                })
                            }
                        })
                        if (warnText == '') {
                            // this.$message.success('添加成功')
                        } else {
                            // this.$message.success('添加成功，' + warnText + '已存在，已自动过滤此单项')
                            this.$message.warning('该套餐已存在，已自动过滤此单项')
                        }
                    }
                )
            }
        },

        addSingle() {
            if (!this.projectForm.planId) {
                this.$message.warning('请选择单项')
            } else {
                console.log(this.sysSetMealPlanListCopy)
                const isExist = this.sysSetMealPlanListCopy.filter(item => { return item.sPlanId == this.projectForm.planId })
                if (isExist.length > 0) {
                    this.$message.warning('已存在，请勿重复添加此单项')
                } else {
                    this.singlePlanList.forEach(item => {
                        if (this.projectForm.planId === item.planId) {
                            this.sysSetMealPlanListCopy.push({
                                pointsNum: 1,//点位数
                                planCategoryId: item.planCategoryId,
                                treatmentType: item.planCategoryId == '2' ? '治疗类' : '',
                                packageContent: item.medicalEquipment,
                                searchValue: item.searchValue,
                                createBy: item.createBy,
                                createTime: item.createTime,
                                updateBy: item.updateBy,
                                updateTime: item.updateTime,
                                remark: item.remark,
                                params: {},
                                id: 0,
                                sPlanId: item.planId,
                                visitNum: item.visitNum,
                                type: "1",
                                category: '2',
                                treatmentModalities: this.matchDict("sys_plan_usage", item.usageId),
                                packageName: '',
                                packageNum: Number(item.planCategoryId),
                                frequency: this.matchDict("sys_dosage_frequency", item.frequencyId),
                                dosage: item.dosage,
                                num: item.num ? item.num : 1,
                                numUnit: this.matchDict("sys_dosage_unit", item.dosageUnit),
                                price: item.price,
                                priceUnit: item.priceUnit,
                                discount: item.discount,
                                diagnosisResult: item.diagnosisResult,
                                diagnosisMedical: item.diagnosisMedical,
                                diagnosisNote: item.diagnosisNote,
                                expenses: item.expenses,
                                status: item.status,
                                instruments: item.instruments,
                                instrumentsIds: item.instrumentsIds,
                                isApplication: item.isApplication,
                                parameters: item.parameters ? this.getParametersValue(item.parameters) : null,
                                parametersList: item.parameters ? JSON.parse(item.parameters) : null,
                                pickingLocation: item.pickingLocation,
                                totalPrice: Number(item.num * item.price),  //添加单项时不用乘item.pointsNum   添加时item.pointsNum默认为1
                                discountPrice: item.discountPrice ? item.discountPrice : Number(item.num * item.price),//添加单项时不用乘item.pointsNum   添加时item.pointsNum默认为1

                            })
                        }
                    })
                    this.projectForm.planId = ''
                }
            }
        },
        updateItemDiagnosis(item) {
            this.currentDiagnosis = item
            this.btnUpdateStatus = true;
            let arr = item.diagnosis.split('、')
            this.projectForm.diseaseClassifyName = arr[0]
            this.getFxAndFq(this.projectForm.diseaseClassifyName);
            // this.projectForm.fxValue = arr[1]
            this.projectForm.fxValue = []
            arr[1].split(',').forEach(item => {
                this.projectForm.fxValue.push(item)
            })
            this.projectForm.fqValue = arr[2]
            this.projectForm.partId = []
            arr[3].split(',').forEach(item => {
                this.projectForm.partId.push(item)
            })

        },
        delDiagnosis(row) {
            console.log('delDiagnosis---', row)
            this.diagnosisList = this.diagnosisList.filter((item) => {
                return row.id != item.id
            })
            if (this.diagnosisList.length > 1) {
                this.diagnosisList.forEach((item, index) => {
                    item.id = index
                })
            }
            // this.projectForm.fxValue = ''
            this.projectForm.fxValue = []
            this.projectForm.fqValue = ''
            this.projectForm.partId = []
        },
        /**添加诊断按钮操作 */
        addDiagnosis() {
            this.$refs["projectForm"].validate((valid) => {
                if (valid) {
                    if (this.projectForm.diseaseClassifyName != "") {
                        this.activeName = ''
                        let arrA = this.dict.type.sys_face_part
                        let arrB = this.projectForm.partId
                        let arrC = arrA.filter(item => arrB.some(citem => item.label === citem))

                        for (const key in arrC) {
                            // 删除raw属性
                            delete arrC[key].raw;
                        }
                        if (this.diagnosisList.length === 0) {
                            this.diagnosisList.push({
                                id: 0,
                                diseaseId: this.projectForm.diseaseId,
                                partArr: arrC,
                                diagnosis: (this.projectForm.diseaseClassifyName ? `${this.projectForm.diseaseClassifyName + '、'}` : "") + (this.projectForm.fxValue.length > 0 ? `${this.projectForm.fxValue + '、'}` : "") + (this.projectForm.fqValue ? `${this.projectForm.fqValue + '、'}` : "") + this.projectForm.partId
                            })
                        } else {
                            this.diagnosisList.push({
                                id: this.diagnosisList.length,
                                partArr: arrC,
                                diseaseId: this.projectForm.diseaseId,
                                diagnosis: (this.projectForm.diseaseClassifyName ? `${this.projectForm.diseaseClassifyName + '、'}` : "") + (this.projectForm.fxValue.length > 0 ? `${this.projectForm.fxValue + '、'}` : "") + (this.projectForm.fqValue ? `${this.projectForm.fqValue + '、'}` : "") + this.projectForm.partId
                            })
                        }
                    } else {
                        this.$message.warning('没有诊断可加入，请选择要加入的诊断')
                    }
                    // console.log('this.projectForm.partId--',this.projectForm.partId)

                    // this.projectForm.fxValue = ''
                    this.projectForm.fxValue = []
                    this.projectForm.fqValue = ''
                    this.projectForm.partId = []
                }
            })
        },
        updateDiagnosis() {
            this.btnUpdateStatus = false;
            this.diagnosisList.forEach((item) => {
                if (item.id === this.currentDiagnosis.id) {
                    item.diagnosis = `${this.projectForm.diseaseClassifyName + '、' + this.projectForm.fxValue + '、' + this.projectForm.fqValue + '、' + this.projectForm.partId}`
                }
            })
            // this.projectForm.fxValue = ''
            this.projectForm.fxValue = []
            this.projectForm.fqValue = ''
            this.projectForm.partId = []
        },
        /** 保存诊断按钮操作 */
        saveDiagnosis() {
        },
        /** 搜索按钮操作 */
        handleQuery() {
        },
        /** 重置按钮操作 */
        resetQuery() {
        },
    },
};
</script>
<style scoped rel="stylesheet/scss"  lang="scss">
.l-h-60 {
    line-height: 60px;
}
.w550{
    width:100%;
}
.btnInput{
  width:calc(100% - 240px)!important;
}
.w300{
    width:300px;
}
.price {
    background-color: #eee;
    line-height: 30px;
    text-align: center;
    color: #1890ff;
    font-size: 16px;
}

.el-form-item--small.el-form-item {
    margin-bottom: 0px;
}

::v-deep .el-input.is-disabled .el-input__inner {
    color: #606266;
}

::v-deep .el-input.is-disabled .el-input__inner {
    color: #1890ff !important;
}

::v-deep .el-collapse-item__header {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mt5 {
    margin-top: 5px;
}

.mt15 {
    margin-bottom: 15px;
    margin-right: 15px;
}

.tips {
    width: 550px;
    line-height: 40px;
    margin: 0 auto 15px auto;
    background-color: #fefa83;
    border-radius: 50px;
    color: #000;
    font-size: 16px;
    text-align: center;
}

::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

::v-deep input[type="number"] {
    -moz-appearance: textfield;
}

.totalItem {
    margin: 0 5px;
}</style>
